package com.cyh.pangu.offer;

/**
 *  https://leetcode-cn.com/problems/bu-yong-jia-jian-cheng-chu-zuo-jia-fa-lcof/solution/jin-zhi-tao-wa-ru-he-yong-wei-yun-suan-wan-cheng-j/
 */
public class Offer65 {
    public int add(int a, int b) {
        while (b != 0) {
            int tempSum = a ^ b;
            int carrySum = (a & b) << 1;
            a = tempSum;
            b = carrySum;
        }
        return a;
    }

    public static void main(String[] args) {
        int a = -1, b = 4;
        Offer65 offer65 = new Offer65();
        int cc = offer65.add(a, b);
        System.out.println("cc:" + cc);
    }
}
